package cn.edu.scau.cmi.zhangjiankun.adapter;

import java.util.ArrayList;
import java.util.List;

import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class AdapterController {
	@FXML
    private TextField inputField1;
	@FXML
	private TextField inputField2;
	@FXML
	private TextArea outputArea;
	
	
	
	
	private List<Student> list = new ArrayList<>();
	private AdapterOfClass aoc = new AdapterOfClass();
	private AdapterOfObject aob = new AdapterOfObject();
	@FXML
	private void initialize() {
    }
	
	public boolean isOkClicked() {
        return true;
    }
	
	
	@FXML
    private void handleOk1() {
		Student student = new Student();
		student.setName(inputField2.getText());
		student.setNum(inputField1.getText());
		list.add(student);
		list=aoc.doTarget(list);
        outputArea.clear();
        for(Student o:list) {
            outputArea.appendText(o.getNum()+o.getName()+"\n");
        }
    }
	
	@FXML
	private void handleOk2() {
		Student student = new Student();
		student.setName(inputField2.getText());
		student.setNum(inputField1.getText());
		list.add(student);
		list=aob.doTarget(list);
        outputArea.clear();
        for(Student o:list) {
            outputArea.appendText(o.getNum()+o.getName()+"\n");
        }
	}
	
}
